clear
clear matrix
clear mata
set more off
set maxvar 32000


cd "/Users/alee87/Dropbox/Agra/"
set scheme plotplainblind

*figure A5
import excel "./Data Entry/agra1901caste.xlsx", sheet("Sheet1") firstrow clear
rename A Caste
graph bar (mean) PercentofLand, over(Caste, sort(PercentofPop) descending)  ytitle(Percent of Land 1901)
 graph2tex, epsfile("./Paper/land_1901")
 graph bar (mean) PercentofPop, over(Caste, sort(PercentofPop) descending)   ytitle(Percent of Population 1901)
 graph2tex, epsfile("./Paper/pop_1901")

 *figure A6
use  "./Analysis/workingdata.dta", clear
egen Total_Landowners =rsum(group10absentees group10residents group9absentees group9residents group8absentees group8residents group7absentees group7residents group6absentees group6residents group5absentees group5residents group4absentees group4residents group3absentees group3residents group2absentees group2residents group1absentees group1residents)
recode Total_Landowners (0=.)
 histogram  Total_Landowners if  Total_Landowners <450 &year==2011,  discrete percent ytitle(Percent of Villages) xtitle(Total Landowners)
 graph2tex, epsfile("./Paper/landowners_hist")

*coefplots (Figures 3-5)
 rename land_1929_single Single_Landlord
  rename absenteeprop Absentee_Landowners
  rename absentee_single Single_LandlordXAbsentee
  
  drop if latitude==.
 
  quietly acreg pg_indexA_1924    Single_Landlord Absentee_Landowners Single_LandlordXAbsentee   logpop_1891   agra_dist subdistown_dist i.soil irrigation71  Lags_pg_indexA_1924 i.subdistrictcode if year==1924, spatial  dist(10) latitude(latitude) longitude(longitude)
 est store est_24
 quietly acreg pg_indexA_1991   Single_Landlord Absentee_Landowners Single_LandlordXAbsentee     logpop_1891   agra_dist subdistown_dist i.soil irrigation71  Lags_pg_indexA_1991 i.subdistrictcode if year==1991, spatial  dist(10) latitude(latitude) longitude(longitude)
 est store est_91
 quietly acreg pg_indexA_2011   Single_Landlord Absentee_Landowners Single_LandlordXAbsentee     logpop_1891   agra_dist subdistown_dist i.soil irrigation71  Lags_pg_indexA_2011 i.subdistrictcode if year==2011, spatial  dist(10) latitude(latitude) longitude(longitude)
est store est_11
coefplot (est*), keep(Single_Landlord Absentee_Landowners Single_LandlordXAbsentee) xline(0) asequation swapnames   coeflabels( est_91 ="1991" est_24 ="1924" est_11 ="2011" )  
 graph2tex, epsfile("./Paper/coefplot_interact")


 foreach var of varlist primaryschool postoffice pg_indexA_1924{
 quietly acreg `var'   upper_vill    logpop_1891   agra_dist subdistown_dist i.soil irrigation71  Lags_`var' i.subdistrictcode if year==1924, spatial  dist(10) latitude(latitude) longitude(longitude)
est store est_`var' 

 }
 coefplot (est*), keep(upper_vill) xline(0) asequation swapnames   coeflabels(est_primaryschool="Primary School" est_postoffice ="Post Office"  est_pg_indexA_1924 ="Public Goods Index")
   estimates clear
 graph2tex, epsfile("./Paper/coefplot_upper_1924")
 
 
 foreach var of varlist primaryschool postoffice middleschool highschool pucca electricity pg_indexA_1991{
 quietly acreg `var'   upper_vill    logpop_1891   agra_dist subdistown_dist i.soil irrigation71  Lags_`var' i.subdistrictcode if year==1991, spatial  dist(10) latitude(latitude) longitude(longitude)
est store est_`var' 

 }
 coefplot (est*), keep(upper_vill) xline(0) asequation swapnames   coeflabels(est_primaryschool="Primary School" est_middleschool="Middle School" est_highschool="High School" est_postoffice ="Post Office" est_puccaroad ="Pucca Road" est_electricity= "Electricity" est_pg_indexA_1991 ="Public Goods Index")
   estimates clear
 graph2tex, epsfile("./Paper/coefplot_upper_1991")
 
  foreach var of varlist primaryschool postoffice middleschool highschool pucca electricity pg_indexA_2011{
 quietly acreg `var'   upper_vill    logpop_1891   agra_dist subdistown_dist i.soil irrigation71  Lags_`var' i.subdistrictcode if year==2011, spatial  dist(10) latitude(latitude) longitude(longitude)
est store est_`var' 

 }
 coefplot (est*), keep(upper_vill) xline(0) asequation swapnames   coeflabels(est_primaryschool="Primary School" est_middleschool="Middle School" est_highschool="High School" est_postoffice ="Post Office" est_puccaroad ="Pucca Road" est_electricity= "Electricity" est_pg_indexA_2011 ="Public Goods Index")
   estimates clear
 graph2tex, epsfile("./Paper/coefplot_upper_2011")

 foreach var of varlist primaryschool postoffice pg_indexA_1924{
 quietly acreg `var'    Absentee_Landowners  logpop_1891   agra_dist subdistown_dist i.soil irrigation71  Lags_`var' i.subdistrictcode if year==1924, spatial  dist(10) latitude(latitude) longitude(longitude)
est store est_`var' 

 }
 coefplot (est*), keep(Absentee_Landowners) xline(0) asequation swapnames   coeflabels(est_primaryschool="Primary School" est_postoffice ="Post Office"  est_pg_indexA_1924 ="Public Goods Index")
   estimates clear
 graph2tex, epsfile("./Paper/coefplot_absentee_1924")
 
 
 foreach var of varlist primaryschool postoffice middleschool highschool pucca electricity pg_indexA_1991{
 quietly acreg `var'   Absentee_Landowners    logpop_1891   agra_dist subdistown_dist i.soil irrigation71  Lags_`var' i.subdistrictcode if year==1991, spatial  dist(10) latitude(latitude) longitude(longitude)
est store est_`var' 

 }
 coefplot (est*), keep(Absentee_Landowners) xline(0) asequation swapnames   coeflabels(est_primaryschool="Primary School" est_middleschool="Middle School" est_highschool="High School" est_postoffice ="Post Office" est_puccaroad ="Pucca Road" est_electricity= "Electricity" est_pg_indexA_1991 ="Public Goods Index")
   estimates clear
 graph2tex, epsfile("./Paper/coefplot_absentee_1991")
 
  foreach var of varlist primaryschool postoffice middleschool highschool pucca electricity pg_indexA_2011{
 quietly acreg `var'   Absentee_Landowners    logpop_1891   agra_dist subdistown_dist i.soil irrigation71  Lags_`var' i.subdistrictcode if year==2011, spatial  dist(10) latitude(latitude) longitude(longitude)
est store est_`var' 

 }
 coefplot (est*), keep(Absentee_Landowners) xline(0) asequation swapnames   coeflabels(est_primaryschool="Primary School" est_middleschool="Middle School" est_highschool="High School" est_postoffice ="Post Office" est_puccaroad ="Pucca Road" est_electricity= "Electricity" est_pg_indexA_2011 ="Public Goods Index")
   estimates clear
 graph2tex, epsfile("./Paper/coefplot_absentee_2011")



 foreach var of varlist primaryschool postoffice middleschool highschool pucca electricity pg_indexA_1991{
 quietly acreg `var'   Single_Landlord    logpop_1891   agra_dist subdistown_dist i.soil irrigation71  Lags_`var' i.subdistrictcode if year==1991, spatial  dist(10) latitude(latitude) longitude(longitude)
est store est_`var' 

 }
 coefplot (est*), keep(Single_Landlord) xline(0) asequation swapnames   coeflabels(est_primaryschool="Primary School" est_middleschool="Middle School" est_highschool="High School" est_postoffice ="Post Office" est_puccaroad ="Pucca Road" est_electricity= "Electricity" est_pg_indexA_1991 ="Public Goods Index")
   estimates clear
 graph2tex, epsfile("./Paper/coefplot_single_1991")
 
  foreach var of varlist primaryschool postoffice middleschool highschool pucca electricity pg_indexA_2011{
 quietly acreg `var'   Single_Landlord    logpop_1891   agra_dist subdistown_dist i.soil irrigation71  Lags_`var' i.subdistrictcode if year==2011, spatial  dist(10) latitude(latitude) longitude(longitude)
est store est_`var' 

 }
 coefplot (est*), keep(Single_Landlord) xline(0) asequation swapnames   coeflabels(est_primaryschool="Primary School" est_middleschool="Middle School" est_highschool="High School" est_postoffice ="Post Office" est_puccaroad ="Pucca Road" est_electricity= "Electricity" est_pg_indexA_2011 ="Public Goods Index")
   estimates clear
 graph2tex, epsfile("./Paper/coefplot_single_2011")


 foreach var of varlist primaryschool postoffice pg_indexA_1924{
 quietly acreg `var'    Single_Landlord   logpop_1891   agra_dist subdistown_dist i.soil irrigation71  Lags_`var' i.subdistrictcode if year==1924, spatial  dist(10) latitude(latitude) longitude(longitude)
est store est_`var' 

 }
 coefplot (est*), keep(Single_Landlord) xline(0) asequation swapnames   coeflabels(est_primaryschool="Primary School" est_postoffice ="Post Office"  est_pg_indexA_1924 ="Public Goods Index")
   estimates clear
 graph2tex, epsfile("./Paper/coefplot_single_1924")
 
 
  
 quietly acreg pg_indexA_2011   brahmin_vill    logpop_1891   agra_dist subdistown_dist i.soil irrigation71  Lags_pg_indexA_2011 i.subdistrictcode if year==2011, spatial  dist(10) latitude(latitude) longitude(longitude)
est store est_pg_indexA_2011 
 quietly acreg pg_indexA_1991   brahmin_vill    logpop_1891   agra_dist subdistown_dist i.soil irrigation71  Lags_pg_indexA_1991 i.subdistrictcode if year==1991, spatial  dist(10) latitude(latitude) longitude(longitude)
est store est_pg_indexA_1991 
 quietly acreg pg_indexA_1924   brahmin_vill    logpop_1891   agra_dist subdistown_dist i.soil irrigation71  Lags_pg_indexA_1924 i.subdistrictcode if year==1924, spatial  dist(10) latitude(latitude) longitude(longitude)
est store est_pg_indexA_1924

 coefplot (est_pg_indexA_1924 est_pg_indexA_1991  est_pg_indexA_2011), keep(brahmin_vill) xline(0) asequation swapnames   coeflabels(est_pg_indexA_2011="2011 Index"  est_pg_indexA_1991="1991 Index" est_pg_indexA_1924="1924 Index")
   estimates clear
 graph2tex, epsfile("./Paper/coefplot_brahmin")
 
 
  
 acreg pg_indexA_2011   jat_vill    logpop_1891   agra_dist subdistown_dist i.soil irrigation71  Lags_pg_indexA_2011 i.subdistrictcode if year==2011, spatial  dist(10) latitude(latitude) longitude(longitude)
est store est_pg_indexA_2011 
  acreg pg_indexA_1991   jat_vill    logpop_1891   agra_dist subdistown_dist i.soil irrigation71  Lags_pg_indexA_1991 i.subdistrictcode if year==1991, spatial  dist(10) latitude(latitude) longitude(longitude)
est store est_pg_indexA_1991 
  acreg pg_indexA_1924   jat_vill    logpop_1891   agra_dist subdistown_dist i.soil irrigation71  Lags_pg_indexA_1924 i.subdistrictcode if year==1924, spatial  dist(10) latitude(latitude) longitude(longitude)
est store est_pg_indexA_1924

 coefplot (est_pg_indexA_1924 est_pg_indexA_1991  est_pg_indexA_2011  ), keep(jat_vill) xline(0) asequation swapnames   coeflabels(est_pg_indexA_2011="2011 Index"  est_pg_indexA_1991="1991 Index" est_pg_indexA_1924="1924 Index")
   estimates clear
 graph2tex, epsfile("./Paper/coefplot_jat")
 
 
  
 quietly acreg pg_indexA_2011   chamar_vill    logpop_1891   agra_dist subdistown_dist i.soil irrigation71  Lags_pg_indexA_2011 i.subdistrictcode if year==2011, spatial  dist(10) latitude(latitude) longitude(longitude)
est store est_pg_indexA_2011 
 quietly acreg pg_indexA_1991   chamar_vill    logpop_1891   agra_dist subdistown_dist i.soil irrigation71  Lags_pg_indexA_1991 i.subdistrictcode if year==1991, spatial  dist(10) latitude(latitude) longitude(longitude)
est store est_pg_indexA_1991 
 quietly acreg pg_indexA_1924   chamar_vill    logpop_1891   agra_dist subdistown_dist i.soil irrigation71  Lags_pg_indexA_1924 i.subdistrictcode if year==1924, spatial  dist(10) latitude(latitude) longitude(longitude)
est store est_pg_indexA_1924

 coefplot (est_pg_indexA_1924 est_pg_indexA_1991  est_pg_indexA_2011), keep(chamar_vill) xline(0) asequation swapnames   coeflabels(est_pg_indexA_2011="2011 Index"  est_pg_indexA_1991="1991 Index" est_pg_indexA_1924="1924 Index")
   estimates clear
 graph2tex, epsfile("./Paper/coefplot_chamar")
 
 

*graphs (figures A3 and A4)



stset year, id( VillageCode) failure(primaryschool ==1) origin(year==1905) exit(primaryschool ==1 )
stdes
stsum

sts graph, by(bigcaste_1891_label)  graphregion(fcolor(white) lcolor(black) lpattern(solid)) plotregion(fcolor(none) ) xtitle(Year)  ytitle(Proportion of Villages Without)   plot1opts(lpattern(dash))  plot2opts(lpattern(solid ) )   xlabel(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011") xmtick(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011")
 graph2tex, epsfile("./Paper/bigcaste_primary")
sts graph, by(land_cat) graphregion(fcolor(white) lcolor(black) lpattern(solid)) plotregion(fcolor(none) ) xtitle(Year)  ytitle(Proportion of Villages Without)   plot1opts(lpattern(dash))  plot2opts(lpattern(solid) )  xlabel(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011") xmtick(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011")
 graph2tex, epsfile("./Paper/landcat_primary")
 sts graph, graphregion(fcolor(white) lcolor(black) lpattern(solid)) plotregion(fcolor(none) ) xtitle(Year)  ytitle(Proportion of Villages Without) xlabel(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011") xmtick(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011")
 graph2tex, epsfile("./Paper/simple_primary")
sts graph, by( upper_vill) graphregion(fcolor(white) lcolor(black) lpattern(solid)) plotregion(fcolor(none) ) xtitle(Year)  ytitle(Proportion of Villages Without)   plot1opts(lpattern(dash))  plot2opts(lpattern(solid))  legend(order( 2  1) label(1 `var' Other Villages) label( 2 Upper Caste Villages)  pos(6) cols(2))  xlabel(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011") xmtick(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011")
 graph2tex, epsfile("./Paper/caste_primary")
  sts graph, by(jat_vill upper_vill) graphregion(fcolor(white) lcolor(black) lpattern(solid)) plotregion(fcolor(none) ) xtitle(Year)  ytitle(Proportion of Villages Without)   plot1opts(lpattern(dash))  plot2opts(lpattern(solid)) plot3opts(lpattern(dash_dot) ) legend(order( 2 3 1) label(1 `var' Other Villages) label( 2 Brahmin Villages) label(3 Jat Villages) pos(6) cols(3))  xlabel(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011") xmtick(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011")
 graph2tex, epsfile("./Paper/castefull_primary")
 
 
stset year, id( VillageCode) failure(postoffice ==1) origin(year==1905) exit(postoffice ==1 )
stdes
stsum

sts graph, by(bigcaste_1891_label)  graphregion(fcolor(white) lcolor(black) lpattern(solid)) plotregion(fcolor(none) ) xtitle(Year)  ytitle(Proportion of Villages Without)   plot1opts(lpattern(dash))  plot2opts(lpattern(solid ) )   xlabel(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011") xmtick(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011")
 graph2tex, epsfile("./Paper/bigcaste_postoffice")
sts graph, by(land_cat) graphregion(fcolor(white) lcolor(black) lpattern(solid)) plotregion(fcolor(none) ) xtitle(Year)  ytitle(Proportion of Villages Without)   plot1opts(lpattern(dash))  plot2opts(lpattern(solid) )  xlabel(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011") xmtick(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011")
 graph2tex, epsfile("./Paper/landcat_postoffice")
  sts graph, graphregion(fcolor(white) lcolor(black) lpattern(solid)) plotregion(fcolor(none) ) xtitle(Year)  ytitle(Proportion of Villages Without) xlabel(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011") xmtick(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011")
 graph2tex, epsfile("./Paper/simple_post")
sts graph, by( upper_vill) graphregion(fcolor(white) lcolor(black) lpattern(solid)) plotregion(fcolor(none) ) xtitle(Year)  ytitle(Proportion of Villages Without)   plot1opts(lpattern(dash))  plot2opts(lpattern(solid))  legend(order( 2  1) label(1 `var' Other Villages) label( 2 Upper Caste Villages)  pos(6) cols(2))  xlabel(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011") xmtick(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011")
 graph2tex, epsfile("./Paper/caste_post")
  sts graph, by(jat_vill upper_vill) graphregion(fcolor(white) lcolor(black) lpattern(solid)) plotregion(fcolor(none) ) xtitle(Year)  ytitle(Proportion of Villages Without)   plot1opts(lpattern(dash))  plot2opts(lpattern(solid)) plot3opts(lpattern(dash_dot) ) legend(order( 2 3 1) label(1 `var' Other Villages) label( 2 Brahmin Villages) label(3 Jat Villages) pos(6) cols(3))  xlabel(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011") xmtick(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011")
 graph2tex, epsfile("./Paper/castefull_post")
 
 stset year, id( VillageCode) failure(middleschool ==1) origin(year==1905) exit(middleschool ==1 )
stdes
stsum

sts graph, by(bigcaste_1891_label)  graphregion(fcolor(white) lcolor(black) lpattern(solid)) plotregion(fcolor(none) ) xtitle(Year)  ytitle(Proportion of Villages Without)   plot1opts(lpattern(dash))  plot2opts(lpattern(solid ) )   xlabel(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011") xmtick(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011")
 graph2tex, epsfile("./Paper/bigcaste_middle")
sts graph, by(land_cat) graphregion(fcolor(white) lcolor(black) lpattern(solid)) plotregion(fcolor(none) ) xtitle(Year)  ytitle(Proportion of Villages Without)   plot1opts(lpattern(dash))  plot2opts(lpattern(solid) )  xlabel(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011") xmtick(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011")
 graph2tex, epsfile("./Paper/landcat_middle")
  sts graph, graphregion(fcolor(white) lcolor(black) lpattern(solid)) plotregion(fcolor(none) ) xtitle(Year)  ytitle(Proportion of Villages Without) xlabel(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011") xmtick(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011")
 graph2tex, epsfile("./Paper/simple_middle")
sts graph, by( upper_vill) graphregion(fcolor(white) lcolor(black) lpattern(solid)) plotregion(fcolor(none) ) xtitle(Year)  ytitle(Proportion of Villages Without)   plot1opts(lpattern(dash))  plot2opts(lpattern(solid))  legend(order( 2  1) label(1 `var' Other Villages) label( 2 Upper Caste Villages)  pos(6) cols(2))  xlabel(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011") xmtick(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011")
 graph2tex, epsfile("./Paper/caste_middle")
  sts graph, by(jat_vill upper_vill) graphregion(fcolor(white) lcolor(black) lpattern(solid)) plotregion(fcolor(none) ) xtitle(Year)  ytitle(Proportion of Villages Without)   plot1opts(lpattern(dash))  plot2opts(lpattern(solid)) plot3opts(lpattern(dash_dot) ) legend(order( 2 3 1) label(1 `var' Other Villages) label( 2 Brahmin Villages) label(3 Jat Villages) pos(6) cols(3))  xlabel(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011") xmtick(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011")
 graph2tex, epsfile("./Paper/castefull_middle")
 
stset year, id( VillageCode) failure(highschool ==1) origin(year==1932) exit(highschool ==1 )
stdes
stsum

sts graph, by(bigcaste_1891_label)  graphregion(fcolor(white) lcolor(black) lpattern(solid)) plotregion(fcolor(none) ) xtitle(Year)  ytitle(Proportion of Villages Without)   plot1opts(lpattern(dash))  plot2opts(lpattern(solid ) )   xlabel(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011") xmtick(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011")
 graph2tex, epsfile("./Paper/bigcaste_high")
sts graph, by(land_cat) graphregion(fcolor(white) lcolor(black) lpattern(solid)) plotregion(fcolor(none) ) xtitle(Year)  ytitle(Proportion of Villages Without)   plot1opts(lpattern(dash))  plot2opts(lpattern(solid) )  xlabel(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011") xmtick(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011")
 graph2tex, epsfile("./Paper/landcat_high")
  sts graph, graphregion(fcolor(white) lcolor(black) lpattern(solid)) plotregion(fcolor(none) ) xtitle(Year)  ytitle(Proportion of Villages Without) xlabel(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011") xmtick(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011")
 graph2tex, epsfile("./Paper/simple_high")
sts graph, by( upper_vill) graphregion(fcolor(white) lcolor(black) lpattern(solid)) plotregion(fcolor(none) ) xtitle(Year)  ytitle(Proportion of Villages Without)   plot1opts(lpattern(dash))  plot2opts(lpattern(solid))  legend(order( 2  1) label(1 `var' Other Villages) label( 2 Upper Caste Villages)  pos(6) cols(2))  xlabel(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011") xmtick(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011")
 graph2tex, epsfile("./Paper/caste_high")
  sts graph, by(jat_vill upper_vill) graphregion(fcolor(white) lcolor(black) lpattern(solid)) plotregion(fcolor(none) ) xtitle(Year)  ytitle(Proportion of Villages Without)   plot1opts(lpattern(dash))  plot2opts(lpattern(solid)) plot3opts(lpattern(dash_dot) ) legend(order( 2 3 1) label(1 `var' Other Villages) label( 2 Brahmin Villages) label(3 Jat Villages) pos(6) cols(3))  xlabel(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011") xmtick(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011")
 graph2tex, epsfile("./Paper/castefull_high")
 
stset year, id( VillageCode) failure(pucca ==1) origin(year==1971) exit(pucca ==1 )
stdes
stsum

sts graph, by(bigcaste_1891_label)  graphregion(fcolor(white) lcolor(black) lpattern(solid)) plotregion(fcolor(none) ) xtitle(Year)  ytitle(Proportion of Villages Without)   plot1opts(lpattern(dash))  plot2opts(lpattern(solid ) )   xlabel(0 "1971" 20 "1991" 30 "2001" 40 "2011" ) xmtick( 0 "1971"  20 "1991" 30 "2001" 40 "2011")
 graph2tex, epsfile("./Paper/bigcaste_pucca")
sts graph, by(land_cat) graphregion(fcolor(white) lcolor(black) lpattern(solid)) plotregion(fcolor(none) ) xtitle(Year)  ytitle(Proportion of Villages Without)   plot1opts(lpattern(dash))  plot2opts(lpattern(solid) )  xlabel(0 "1971" 20 "1991" 30 "2001" 40 "2011" ) xmtick( 0 "1971"  20 "1991" 30 "2001" 40 "2011")
 graph2tex, epsfile("./Paper/landcat_pucca")
 sts graph,  graphregion(fcolor(white) lcolor(black) lpattern(solid)) plotregion(fcolor(none) ) xtitle(Year)  ytitle(Proportion of Villages Without)   xlabel(0 "1971" 20 "1991" 30 "2001" 40 "2011" ) xmtick( 0 "1971"  20 "1991" 30 "2001" 40 "2011")
 graph2tex, epsfile("./Paper/simple_pucca")
sts graph, by( upper_vill) graphregion(fcolor(white) lcolor(black) lpattern(solid)) plotregion(fcolor(none) ) xtitle(Year)  ytitle(Proportion of Villages Without)   plot1opts(lpattern(dash))  plot2opts(lpattern(solid))  legend(order( 2  1) label(1 `var' Other Villages) label( 2 Upper Caste Villages)  pos(6) cols(2))  xlabel(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011") xmtick(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011")
 graph2tex, epsfile("./Paper/caste_pucca")
  sts graph, by(jat_vill upper_vill) graphregion(fcolor(white) lcolor(black) lpattern(solid)) plotregion(fcolor(none) ) xtitle(Year)  ytitle(Proportion of Villages Without)   plot1opts(lpattern(dash))  plot2opts(lpattern(solid)) plot3opts(lpattern(dash_dot) ) legend(order( 2 3 1) label(1 `var' Other Villages) label( 2 Brahmin Villages) label(3 Jat Villages) pos(6) cols(3))  xlabel(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011") xmtick(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011")
 graph2tex, epsfile("./Paper/castefull_pucca")
 
 stset year, id( VillageCode) failure(electricity ==1) origin(year==1961) exit(electricity ==1 )
stdes
stsum

sts graph, by(bigcaste_1891_label)  graphregion(fcolor(white) lcolor(black) lpattern(solid)) plotregion(fcolor(none) ) xtitle(Year)  ytitle(Proportion of Villages Without)   plot1opts(lpattern(dash))  plot2opts(lpattern(solid ) )   xlabel(0 "1961" 10 "1971" 30 "1991" 40 "2001" 50 "2011" ) xmtick( 0 "1961" 10 "1971" 30 "1991" 40 "2001" 50 "2011")
 graph2tex, epsfile("./Paper/bigcaste_electricity")
sts graph, by(land_cat) graphregion(fcolor(white) lcolor(black) lpattern(solid)) plotregion(fcolor(none) ) xtitle(Year)  ytitle(Proportion of Villages Without)   plot1opts(lpattern(dash))  plot2opts(lpattern(solid) )  xlabel(0 "1961" 10 "1971" 30 "1991" 40 "2001" 50 "2011" ) xmtick( 0 "1961" 10 "1971" 30 "1991" 40 "2001" 50 "2011")
 graph2tex, epsfile("./Paper/landcat_electricity")
 sts graph,  graphregion(fcolor(white) lcolor(black) lpattern(solid)) plotregion(fcolor(none) ) xtitle(Year)  ytitle(Proportion of Villages Without)   xlabel(0 "1961" 10 "1971" 30 "1991" 40 "2001" 50 "2011" ) xmtick( 0 "1961" 10 "1971" 30 "1991" 40 "2001" 50 "2011")
 graph2tex, epsfile("./Paper/simple_electricity")
sts graph, by( upper_vill) graphregion(fcolor(white) lcolor(black) lpattern(solid)) plotregion(fcolor(none) ) xtitle(Year)  ytitle(Proportion of Villages Without)   plot1opts(lpattern(dash))  plot2opts(lpattern(solid))  legend(order( 2  1) label(1 `var' Other Villages) label( 2 Upper Caste Villages)  pos(6) cols(2))  xlabel(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011") xmtick(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011")
 graph2tex, epsfile("./Paper/caste_electricity")
  sts graph, by(jat_vill upper_vill) graphregion(fcolor(white) lcolor(black) lpattern(solid)) plotregion(fcolor(none) ) xtitle(Year)  ytitle(Proportion of Villages Without)   plot1opts(lpattern(dash))  plot2opts(lpattern(solid)) plot3opts(lpattern(dash_dot) ) legend(order( 2 3 1) label(1 `var' Other Villages) label( 2 Brahmin Villages) label(3 Jat Villages) pos(6) cols(3))  xlabel(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011") xmtick(0 "1905" 9 "1914" 19 "1924" 27 "1932" 46 "1951" 56 "1961" 66 "1971"  86 "1991" 96 "2001" 106 "2011")
 graph2tex, epsfile("./Paper/castefull_electricity")
 
 
 
 stop
 ***CM caste*** Figure A7
gen Brahmin =brahmin_vill 
gen Yadav =yadav_vill 
gen Lodh =lohda_vill 
gen Rajput =rajput_vill 
gen Chamar= chamar_vill 
gen Jat =jat_vill 
gen one=1
gen pointthree=.4
drop if year>2011

merge m:m year using  "/Users/alee87/Dropbox/Agra/Analysis/upcm.dta"
drop if _merge==1

cd "/Users/alee87/Dropbox/Agra/"
 foreach var of varlist Brahmin Yadav Lodh Rajput  Chamar Jat{
 preserve

 collapse (mean) primaryschool postoffice middleschool highschool pucca elec one pointthree `var'_CM, by(`var' year)

 twoway (bar `var'_CM year, sort fcolor(gray%20) lcolor(none%0) barw(0.25)) (line primary year if `var'==0, lpattern(solid))(line primary year if `var'==1,  lpattern(dash))  , title(Primary Schools) ytitle(Proportion of Villages with Good) xtitle(Year) xlabel(1951 1961 1971 1991 2001 2011) legend(order(1 2 3) label(1 `var' Chief Minister) label( 2 Other Villages) label(3 `var' Villages) pos(6) cols(3))
  *graph2tex, epsfile("./Paper/`var'_primary")
  recode `var'_CM (1=.4)
  
  keep if year>1951
  twoway (bar `var'_CM year, sort fcolor(gray%20) lcolor(none%0) barw(0.25)) (line post year if `var'==0, lpattern(solid))(line post year if `var'==1,  lpattern(dash)), title(Post Offices) ytitle(Proportion of Villages with Good) xtitle(Year) xlabel(1951 1961 1971 1991 2001 2011) legend(order(1 2 3) label(1 `var' Chief Minister) label( 2 Other Villages) label(3 `var' Villages) pos(6) cols(3))
 *  graph2tex, epsfile("./Paper/`var'_post")
 restore
 }

 
 
 
